<template>
  <div>
    <Navbar class="nav-bar">
      <div class="back" slot="left" @click="back">
        <img src="../../../assets/img/back/back.png" alt="" />
      </div>
      <div slot="center" class="center">
        <div
          v-for="(item, index) in titles"
          :key="index"
          class="item"
          :class="{ active: index == currentindex }"
          @click="titleclick(index)"
        >
          {{ item }}
        </div>
      </div>
    </Navbar>
  </div>
</template>

<script>
import Navbar from "../../../components/common/navbar/Navbar";
export default {
  name: "detailnavbar",
  components: {
    Navbar,
  },
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentindex: 0,
    };
  },
  methods: {
    titleclick(index) {
      this.currentindex = index;
    },
    back(){
        // 点击按钮返回上一级
        this.$router.back()
    }
  },
};
</script>

<style scoped>
.nav-bar{
  background-color: #fff;
}
.center {
  display: flex;
}
.center .item {
  flex: 1;
}
.active {
  color: var(--color-high-text);
}
.back img {
  width: 20px;
  margin-top: 13px;
}
</style>